// Copyright (C) ustc9703
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-7-12

#ifndef __THREADPOOL_H_COMMON_SERVER_
#define __THREADPOOL_H_COMMON_SERVER_

#pragma once

class CJoyAsyObject
{
protected:
    volatile long m_asyState;
public:
    CJoyAsyObject()
    {
        m_asyState = 0;
    }
    virtual ~CJoyAsyObject(){}

    virtual void Cancel();
    virtual void Execute();
    virtual void Finish();

    virtual void OnExecute() = 0;
    virtual void OnFinish(){}
};

class CJoyThreadWorker
{
public:
    typedef CJoyAsyObject* RequestType;

    virtual BOOL Initialize(void *)
    {
        return TRUE;
    }
    virtual void Terminate(void* /*pvParam*/)
    {
	}

	void Execute(RequestType pAsyObj, void *, OVERLAPPED* ) throw();
};

class CJoyThreadPool : public CThreadPool<CJoyThreadWorker>
{
public:
    CJoyThreadPool(void);
    virtual ~CJoyThreadPool(void);
};

#endif  // __THREADPOOL_H_COMMON_SERVER_